from sqlalchemy import Column, Integer, String, Text, DateTime, func
from .base import Base

class StrategyConfig(Base):
    """
    策略配置表模型
    """
    __tablename__ = 'strategy_configs'

    id = Column(Integer, primary_key=True, index=True)
    strategy_name = Column(String(100), nullable=False, index=True, comment="策略类名, 例如 'SARStrategy'")
    symbol = Column(String(50), nullable=False, index=True, comment="交易对, 例如 'ETH-USDT'")
    parameters_json = Column(Text, nullable=False, comment="策略参数的JSON字符串")
    is_active = Column(Integer, nullable=False, default=1, comment="是否启用, 1:启用, 0:禁用")
    created_at = Column(DateTime(timezone=True), server_default=func.now(), comment="创建时间")
    updated_at = Column(DateTime(timezone=True), onupdate=func.now(), comment="更新时间")

    def __repr__(self):
        return f"<StrategyConfig(strategy_name='{self.strategy_name}', symbol='{self.symbol}', is_active={self.is_active})>" 